package com.bwie.gddproject.index.view.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bwie.gddproject.R;
import com.bwie.gddproject.index.adapter.MyGridAdapter;
import com.bwie.gddproject.index.model.bean.VpBean;
import com.bwie.gddproject.index.precenter.VpPrecenter;

import java.util.List;

/**
 * Created by 我走路带风 on 2017/12/15.
 */

public class GridFragment extends Fragment implements IGridFragment {

    private RecyclerView rv;
    private VpPrecenter vpPrecenter;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(getContext(), R.layout.home_vp_page1, null);
        rv = (RecyclerView) view.findViewById(R.id.home_vp_rv1);
        vpPrecenter = new VpPrecenter(this);
        vpPrecenter.getVpData();
        return view;
    }

    @Override
    public void showVpFrag(VpBean vpBean) {
        List<VpBean.DataBean> data = vpBean.getData();
        MyGridAdapter myGridAdapter = new MyGridAdapter(getActivity(), data);

        rv.setLayoutManager(new GridLayoutManager(getContext(), 5));
        rv.setAdapter(myGridAdapter);

    }
    @Override
    public void toast(String str) {

    }
}
